#ifndef __MAINWINDOW_H
#define __MAINWINDOW_H

#include "Common.h"
#include "Debugger.h"



class QCompleter;

class Highlighter : public QSyntaxHighlighter
{
    Q_OBJECT

public:
    enum Construct
    {
       String,
       Clip,
       Tag,
       Comment,
       LastConstruct = Comment
    };

    Highlighter(QTextDocument *parent = 0);
    void setFormatFor(Construct construct, const QTextCharFormat &format);

    QTextCharFormat formatFor(Construct construct)
    {
        return m_formats[construct];
    }

protected:
    enum State
    {
        NormalState = -1,
        InComment,
        InTag,
        InString,
        InSingleComment,
    };

    void highlightBlock(const QString &text);

private:
    QTextCharFormat m_formats[LastConstruct + 1];

    struct HighlightingRule
    {
        QRegExp pattern;
        QTextCharFormat format;
    };

    QVector<HighlightingRule> highlightingRules;

    QRegExp commentStartExpression;
    QRegExp commentEndExpression;

    QTextCharFormat keywordFormat;
    QTextCharFormat extraFormat;
    QTextCharFormat classFormat;
    QTextCharFormat singleLineCommentFormat;
    QTextCharFormat multiLineCommentFormat;
    QTextCharFormat quotationFormat;
    QTextCharFormat functionFormat;
};


namespace Ui
{
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

    void on_actionOeffnen_triggered(QString nameFile);
    int GetColumn();
    int GetBlock();

    QAction *column;
    QTextEdit *edit;
    QWidget *centralWidget;

private:
    void setupMenu();
    void setupShortcuts();
    int pos;
    bool saved;
    Ui::MainWindow *ui;
    QString filepath;
   // QCompleter *completer;
    Debugger* d;

    Highlighter *highlighter;

private slots:
    void on_undo_triggered();
    void on_actionBeenden_triggered();
    bool on_actionSpeichern_activated();
    void on_actionNeu_triggered();
    bool onSave();
    void goTo();
    void textColor();
    void redo();
    void cut();
    void copy();
    void paste();
    void UpdateColoumn();
    void on_actionOeffnen_triggered();
    bool CheckSyntax();
    void Unsave();
    bool search();
};

#endif // __MAINWINDOW_H
